<%-- 
    Document   : loginAction
    Created on : 11 8, 10, 3:29:38 PM
    Author     : CCS
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="UserPackage.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>

        
    </head>
   <body background ="http://img530.imageshack.us/img530/6118/bg2k0.jpg">
        <center><br><br><br><br>
       <%
            int i= 0;
            String username = request.getParameter("username");
            String password = request.getParameter("password");
/*
            boolean result = new UserManager().checkUser(username, password);
            boolean result1 = new UserManager().checkProdMgr(username, password);
           
            boolean result2 = new UserManager().checkAcctMgr(username, password);
           */
          //if(session.getAttribute("userAttempt").equals("5")){
          if(new UserManager().checkUser(username, password)){
                session.setAttribute("username", username);
                session.setAttribute("userType", "4");
                request.setAttribute("username", username);
                request.setAttribute("userType", "4");
                
               // request.setAttribute("password", password);
                response.sendRedirect("userHomePage.jsp");
                }
           
           
           else if(new UserManager().checkProdMgr(username, password)){
                session.setAttribute("username", username);
                session.setAttribute("userType", "2");
                request.setAttribute("username", username);
                request.setAttribute("userType", "2");
                
                //request.setAttribute("password", password);
                response.sendRedirect("prodMgrHomePage.jsp");
                  }
            
            
         
           else if(new UserManager().checkAcctMgr(username, password)){
                session.setAttribute("username", username);
                session.setAttribute("userType", "3");
                request.setAttribute("username", username);
                request.setAttribute("userType", "3");
                
                //request.setAttribute("password", password);
                response.sendRedirect("acctMgrHomePage.jsp");
                }
            
          else
              // session.setAttribute("userAttempts", i++);
            //   request.setAttribute("userAttempts", i);
               response.sendRedirect("home.jsp");
              //        }
            //else
            //    response.sendRedirect("invalidLogin.jsp");
               
            
                                  
       %>
        </center>
    </body>
</html>
